package com.example.mywechat;

import androidx.fragment.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;


/**
 * A simple {@link Fragment} subclass.
 */
public class friendFragment extends Fragment {
    private RecyclerView recyclerView;
    private List<String> myList = new ArrayList<>();
    private Context context;
    private friend_adapter adapter;

    public friendFragment() {
        // Required empty public constructor
    }

    private void initData(){
        myList.add("SN");
        myList.add("TES");
        myList.add("JDG");
        myList.add("LGD");
        myList.add("IG");
        myList.add("V5");
        myList.add("WE");
        myList.add("VG");
        myList.add("RNG");
        myList.add("FPX");
        myList.add("BLG");
        myList.add("OMG");
        myList.add("EDG");
        myList.add("ES");
        myList.add("RW");
        myList.add("LNG");
    }

    private void initView2(){
        context=this.getActivity();
        adapter=new friend_adapter(context,myList);

        LinearLayoutManager manager2=new LinearLayoutManager(context);
        manager2.setOrientation(LinearLayoutManager.VERTICAL);

        recyclerView.setAdapter(adapter);
        recyclerView.setLayoutManager(manager2);
        recyclerView.setHasFixedSize(true);
        recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view= inflater.inflate(R.layout.tab02, container, false);
        recyclerView=view.findViewById(R.id.rcv2);
        initData();
        initView2();

        return view;
    }

}
